package com.example.demo.thread.ticketdemo;

/**
 *
 * count--不是原子性。多线程调用的话，会造成线程不安全
 *
 * @author luowj12
 * @since 2021/4/16 15:21
 */
public class TicketThread implements  Runnable {
    private volatile  int count=50;

    private static   int count1=50;

    @Override
    public void run() {
        while (count > 0){
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+":  抢到第"+count--+"张");
        }
    }
}
